<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>超市订单管理系统</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css"/>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css"/>
</head>
<body>

       <div class="location">
           <strong>你现在所在的位置是:</strong> <span>订单管理页面</span>
       </div>
       	
		<div class="${updateClass }">${updateMsg }</div>
		<c:remove var="updateMsg" scope="session"/>
		<c:remove var="updateClass" scope="session"/>
	
        <div class="search">
            <form method="get" action="/jsp/bill.do" id="form1">
                <input name="method" value="query" class="input-text" type="hidden">
                <span>商品名称：</span>
                <input name="name" type="text" value="${name }">

                <span>供应商：</span>
                <select name="provider">
                    <option value="">--请选择--</option>
					 <c:forEach items="${paProvider.items }" var="t">
						 <option value="${t.name }" <c:if test="${provider == t.name }">selected</c:if>>${t.name }</option>
					 </c:forEach>
                </select>
                <span>是否付款：</span>
                <select name="state">
                    <option value="">--请选择--</option>
                    <option value="2" <c:if test="${state == '2' }">selected</c:if>>未付款</option>
                    <option value="1" <c:if test="${state == '1' }">selected</c:if>>已付款</option>
                </select>

                <input value="查 询" type="button" id="searchbutton">
                <a href="javascript:toJump('${pageContext.request.contextPath}/page/bill/orderAdd.jsp', '', '#mainframe')">添加订单</a>
            </form>
        </div>
        <!--账单表格 样式和供应商公用-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">订单编码</th>
                <th width="20%">商品名称</th>
                <th width="10%">供应商</th>
                <th width="10%">订单金额</th>
                <th width="10%">是否付款</th>
                <th width="10%">创建时间</th>
                <th width="30%">操作</th>
            </tr>

	<c:forEach items="${paBill.items }" var="t">
		<tr>
			<td><span>${t.idName }</span></td>
			<td><span>${t.name }</span></td>
			<td><span>${t.provider }</span></td>
			<td><span>${t.money }</span></td>
			<td><span>${t.state==1?'已付款':'未付款'}</span></td>
			<td><span>${t.time }</span></td>
			<td><span> 
					<a class="viewUser" 
						href="javascript:toJump('${pageContext.request.contextPath}/bill/orderDetail', 'id=${t.id }&page=orderDetail.jsp', '#mainframe')"> 
						<img src="${pageContext.request.contextPath}/images/read.png" 
							alt="查看" title="查看"/>
					</a>
				</span>
				<span> 
					<a class="modifyUser" 
						href="javascript:javascript:toJump('${pageContext.request.contextPath}/bill/orderDetail', 'id=${t.id }&page=orderUpdate.jsp', '#mainframe')">
						<img src="${pageContext.request.contextPath}/images/xiugai.png"
							alt="修改" title="修改" />
					</a>
				</span>
				<span> 
					<a class="deleteUser" onclick="return confirm('确定删除订单编码为${t.idName}的  ${t.name }吗?') "
					href="javascript:javascript:toJump('${pageContext.request.contextPath}/bill/remove', 'id=${t.id }&curr=${paBill.curr}', '#mainframe')"> 
						<img src="${pageContext.request.contextPath}/images/schu.png" 
							alt="删除" title="删除" />
					</a>
				</span>
			</td>
		</tr>
		</c:forEach>
        </table>
	<input type="hidden" id="totalPageCount" value="3" />

	<div class="page-bar">
		<ul class="page-num-ul clearfix">
			<li>共${paBill.count }条记录&nbsp;&nbsp; ${paBill.curr }/${paBill.total }页</li>
			&nbsp;&nbsp;
			<a href="javascrip:void(0)">首页</a>
			<a href="javascrip:void(0)">上一页</a>
			<a href="javascrip:void(0)">下一页</a> 
			<a href="javascrip:void(0)">最后一页</a> &nbsp;&nbsp;
		</ul>
		<span class="page-go-form"><label>跳转至</label> 
		<input	type="text" name="inputPage" id="inputPage" class="page-key" value="${paBill.curr }"/>页
			<button type="button" class="page-btn" )'>GO</button>
		</span>
	</div>
<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeBi">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该订单吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div> 

<footer class="footer">
    版权归北大青鸟
</footer>
</body>

<!-- 保存当前页的后台路径和参数 -->
<c:set var="urlLoading" value="${pageContext.request.contextPath}/bill/query" scope="session"></c:set>
<c:set var="paramLoading" value="curr=${paBill.curr }" scope="session"></c:set>

<script type="text/javascript">
/* 设置翻页的超连接是否显示 */
 var curr = "${paBill.curr }";
 var total = "${paBill.total }";
 var count = "${paBill.count }";
//判断是否是第一页
if(curr == 1){
	$(".page-num-ul a:lt(2)").hide();
}
//判断是否是最后一页
if(curr == total || count == 0){
	$(".page-num-ul a:gt(1)").hide();
}
$(".page-num-ul a:eq(0)").bind("click", function() {
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize() + "&curr=1", "#mainframe"
	);
});
$(".page-num-ul a:eq(1)").bind("click", function() {
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize() + "&curr=${paBill.curr-1}", "#mainframe"
	);
});
$(".page-num-ul a:eq(2)").bind("click", function() {
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize() + "&curr=${paBill.curr+1}", "#mainframe"
	);
});
$(".page-num-ul a:eq(3)").bind("click", function() {
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize() + "&curr=${paBill.total}", "#mainframe"
	);
});

$(".page-go-form .page-btn").bind("click", function() {
	//获取跳转目标页码
	var target = $(".page-go-form .page-key").val();
	//获取当前页
	var curr = "${paBill.curr}";
	//获取总页数
	var total = "${paBill.total}";
	
	//判断, target的值是否符合数值格式
	if(!/^\d+$/.test(target)) {
		$(".page-go-form .page-key").val(curr);
		return;
	}
	//判断, target是否在合理的范围内
	if(target == curr || target < 1 || target > total){
		$(".page-go-form .page-key").val(curr);
		return;
	}
	
	//跳转
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize() + "&curr="+target, "#mainframe"
	);
});

//为查询按钮绑定事件
$("#searchbutton").bind("click", function() {
	toJump(
		"${pageContext.request.contextPath}/bill/query",
		$("#form1").serialize(), "#mainframe"
	);
});

</script>
</html>
